package Greed;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with Intellij IDEA
 * Description:
 * User: 星辰
 */
public class SortThePeople {
    //按身高排序
    public String[] sortPeople(String[] names, int[] heights) {
        int n=names.length;
        Integer[] num=new Integer[n];
        for (int i = 0; i <n ; i++) {
            num[i]=i;
        }
        Arrays.sort(num,(i,j)->
        {
            return heights[j]-heights[i];
        });
        String[] ret=new String[n];
        for (int i = 0; i < n; i++) {
            ret[i]=names[num[i]];
        }
        return ret;
    }
}
